'''
Created on Mar 15, 2011

@author: brendenjeon
'''
import unittest
import csv

import datetime
from google.appengine.ext import db
from google.appengine.tools import bulkloader
import models

"""
class Album(db.Model):
    artist = db.StringProperty()
    title = db.StringProperty()
    publication_date = db.DateProperty()
    length_in_minutes = db.IntegerProperty()

class AlbumLoader(bulkloader.Loader):
    def __init__(self):
        bulkloader.Loader.__init__(self, 'Album',
                                   [('title', str),
                                    ('artist', str),
                                    ('publication_date',
                                     lambda x: datetime.datetime.strptime(x, '%m/%d/%Y').date()),
                                    ('length_in_minutes', int)
                                   ])

loaders = [AlbumLoader]
"""

def uplaod_school():
    infile = csv.reader(open('school.csv', 'rb'))
    for row in infile:
        print ','.join(row)

class SchoolLoader(bulkloader.Loader):
    def __init__(self):
        bulkloader.Loader.__init__(self, 'Album',
                                   [('title', str),
                                    ('artist', str),
                                    ('publication_date',
                                     lambda x: datetime.datetime.strptime(x, '%m/%d/%Y').date()),
                                    ('length_in_minutes', int)
                                   ])


def upload_orginal_invoice():
    infile = csv.reader(open('all_invoice.csv', 'rb'))

    #remove header
    for n in xrange(3):
        infile.next()

    for row in infile:
        print ','.join(row)

if __name__ == "__main__":
    uplaod_school()
#    upload_orginal_invoice()

